﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;

namespace ProlificNotion.Umbraco.DataTypes
{
    public class FilteredMemberPicker : DropDownList
    {
        /// <summary>
        /// Binds a data source to the invoked server control and all its child controls.
        /// </summary>
        public override void DataBind()
        {
            this.Items.Clear();
            base.DataBind();
        }

        /// <summary>
        /// Calls the <see cref="M:System.Web.UI.WebControls.BaseDataBoundControl.DataBind"/> method if the <see cref="P:System.Web.UI.WebControls.BaseDataBoundControl.DataSourceID"/> property is set and the data-bound control is marked to require binding.
        /// </summary>
        protected override void EnsureDataBound()
        {
            try
            {
                if (this.RequiresDataBinding)
                {
                    this.DataBind();
                }
            }
            catch { }
        }
    }
}
